<template>
  <zm-dialog
    :title="dialogParams.title||'高级查询'"
    :visible.sync="value"
    append-to-body
    size="small"
    :before-close="dialogClose"
    :close-on-click-modal="false"
  >
    <el-form :model="query" inline label-width="110px" label-position="left">
      <el-form-item
        v-for="(item,index) in formList"
        :key="index"
        :label="item[labelKey]"
        class="wp30 mr15"
      >
        <el-input
          type="text"
          v-model="query[item[vmodelKey]]"
          clearable
          :placeholder="`请输入${item[labelKey]}`"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="tr">
      <el-button size="small" @click="dialogClose">取消</el-button>
      <el-button size="small" type="primary" @click="submit">确定</el-button>
    </div>
  </zm-dialog>
</template>

<script>
import dialogMixin from '@/mixins/dialogMixin'
export default {
  mixins: [dialogMixin],
  props: {
    value: {
      type: Boolean,
      default: false
    },
    dialogParams: {
      type: Object,
      default: () => {
        return {
          formList: [],
          query: {}
        }
      }
    }

  },
  data () {
    return {
      formList: [],
      query: {},
      labelKey: 'label',
      vmodelKey: 'value'
    }
  },
  created () {
    this.formList = this.dialogParams.formList || []
    this.query = Object.assign({}, this.query, this.dialogParams.query) || {}
    this.labelKey = this.dialogParams.labelKey || 'label'
    this.vmodelKey = this.dialogParams.vmodelKey || 'value'
  },
  methods: {
    submit () {
      this.$emit('after-save', this.query)
      this.dialogClose()
    }
  }
}
</script>
